package com.github.zhijieqing.socket.cluster.websocket;

import com.github.zhijieqing.socket.cluster.common.manager.SocketManagerUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;

@Slf4j
public class SessionDisconnectListener implements ApplicationListener<SessionDisconnectEvent> {
    @Override
    public void onApplicationEvent(SessionDisconnectEvent event) {
        log.info("WS连接【{}】断开",event.getSessionId());
        SocketManagerUtils.getInstance().removeSession(event.getSessionId());
    }
}
